<template>
	<div class="shandongdianxin" style="padding: 20px;">
		<el-table :data="tableData" style="text-align: center;" align="center" border :loading="loading">
			<el-table-column label="模板名称" >
				<template slot-scope="scope">
					<span>{{ scope.row.name }}</span>
				</template>
			</el-table-column>
			<el-table-column label="状态">
				<template slot-scope="scope">
					<span v-if="scope.row.status == 0"> 待审核</span>
					<span v-if="scope.row.status == 1"> 通过</span>
					<span v-if="scope.row.status == 2"> 拒绝</span>
				</template>
			</el-table-column>
			<el-table-column label="审核失败原因">
				<template slot-scope="scope">
					<span>{{ scope.row.reason }}</span>
				</template>
			</el-table-column>
			
			<el-table-column label="类型">
				<template slot-scope="scope">
					<span v-if="scope.row.type == 1">下单提醒</span>
					<span v-if="scope.row.type == 2">订单信息完善</span>
					<span v-if="scope.row.type == 3">开卡结果通知</span>
					<span v-if="scope.row.type == 4">发货通知</span>
					<span v-if="scope.row.type == 5">催促激活</span>
					<span v-if="scope.row.type == 6">其他</span>
				</template>
			</el-table-column>
			
			<el-table-column label="内容">
				<template slot-scope="scope">
					<span>{{ scope.row.content }}</span>
				</template>
			</el-table-column>
			
			<el-table-column label="创建时间">
				<template slot-scope="scope">
					<span>{{ scope.row.created_at }}</span>
				</template>
			</el-table-column>
			<el-table-column label="操作">
				<template slot-scope="scope">
					<el-button type="text" @click="shenhe(1,scope.row.id)">审核通过</el-button>
					<el-button type="text" @click="shenhe(2,scope.row.id)">审核拒绝</el-button>
				</template>
			</el-table-column>
		</el-table>

	</div>
</template>

<script>
	import axios from 'axios'
	export default {
		name: 'duanxinmobanshenhe',
		data() {
			return {
				all: {
					pagesize: 20,
					page: 1,
				},
				tableData: "",
				total:"",
				loading:true
			}
		},
		watch: {
			
		},
		computed: {
			
		},
		created() {
			this.getlist()
		},
		methods: {
			shenhe:function(status,id){
				if(status == 2){
					this.$prompt('请输入拒绝的理由', '提示', {
					  confirmButtonText: '确定',
					  cancelButtonText: '取消',
					}).then(({ value }) => {
					  axios.post('/api/plan-market/message/formwork/review',{status:status,id:id,reason:value})
					  	.then(response => {
					        if(response.data.msg.code == 0){
					  			this.$message.success('已拒绝');
					  			this.getlist()
					        }
					  	  else {
					  	  	this.$message.error(response.data.msg.info);
					  	  }
					  	})
					})
				}else{
					axios.post('/api/plan-market/message/formwork/review',{status:status,id:id})
						.then(response => {
					      if(response.data.msg.code == 0){
								this.$message.success('已通过');
								this.getlist()
					      }
						  else {
						  	this.$message.error(response.data.msg.info);
						  }
						})
				}
				
				
			},
			//翻页
			fanye: function(page) {
				this.loading = true
				this.all.page = page
				this.getlist()
			},
			//获取全部
			getlist:function(){
			    var that = this
			    axios.get('/api/plan-market/message/pending/approval')
			    	.then(response => {
			          if(response.data.msg.code == 0){
							this.tableData = response.data.data

							this.loading = false
			          }
					  else {
					  	this.$message.error(response.data.msg.info);
					  }
			    	})
			},
			
		},

	}
</script>

<style scoped>
	.shandongdianxin {
		
	}
</style>
